package proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ProxyHandler implements InvocationHandler {

    private Object object;

    public ProxyHandler(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        this.sale();
        method.invoke(object, args);
        this.give();
        return null;
    }

    private void sale(){
        System.out.println("打折");
    }

    private void give(){
        System.out.println("赠送代金券");
    }
}
